package com.example.playnote.viewModel

import androidx.lifecycle.MutableLiveData
import com.example.playnote.bean.LoginResponse
import com.example.playnote.net.ApiResponse
import com.example.playnote.net.NetworkApi
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.requestNoCheck

/**
 * 登录注册
 */
class LoginViewModel: BaseViewModel() {
    val loginResult = MutableLiveData<ApiResponse<LoginResponse>>()
    val registerResult = MutableLiveData<ApiResponse<LoginResponse>>()
    fun login(userName: String, password: String) {
        requestNoCheck({
            NetworkApi.service.login(userName, password)
        }, {
            loginResult.postValue(it)
        }, {}, false)
    }

    fun register(userName: String, password: String) {
        requestNoCheck({
            NetworkApi.service.register(userName, password)
        },{
            registerResult.postValue(it)
        },{},false)
    }
}